<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
		"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
	<title>素材管理</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0"><!-- 确保适当的绘制和触屏缩放 -->
	<link rel="stylesheet" href="{$url_css}bootstrap.min.css" type="text/css">
	<link rel="stylesheet" href="{$url_css}admin.css" type="text/css">
	<link rel="stylesheet" href="{$url_css}viewer.min.css" type="text/css"/>

	<script type="text/javascript" src="{$url_js}jquery-1.12.0.min.js"></script>
	<script type="text/javascript" src="{$url_js}viewer-jquery.min.js"></script>
</head>
<body>

<div class="container" style="width:96%">
	<table class="table table-bordered table-striped" align="center">
		<tr>
			<td><a href="?do=Edit" class="btn btn-primary">添加素材</a></td>
		</tr>
	</table>
	<table class="table table-bordered table-striped table-hover" align="center">
		<thead>
		<tr>
			<td colspan="9">素材列表</td>
		</tr>
		</thead>
		<tbody>
		<tr>
			<td>ID</td>
			<td>URL地址</td>
			<td>活动图</td>
			<td>操作</td>
		</tr>

		{if !empty($list)}
			{foreach $list as $k=> $v}
				<tr id="d{$v.Id}">
					<td align="center">{$v.Id}</td>
					<td align="center">{$v.Url}</td>
					<td align="center">
						<a class="img" target="_blank"><img src="{$v.ImgUrl}" width="100px" alt=""/><a/>
					</td>
					<td align="center">
						<a href="?do=edit&id={$v.Id}" class="btn btn-info">修改</a>
						<br>
						<a class="btn btn-danger" onclick="deleteMatter({$v.Id})">删除</a>
					</td>
				</tr>
			{/foreach}
		{/if}
		</tbody>
	</table>
	{if !empty($pagination)}
		<table class="table table-bordered table-striped" align="center">
			<tr>
				<td colspan="7" align="right">
					<div class="page_info">
						{if $page_info['count']}
							<div class="p_l">一共 {$page_info['count']} 条数据,共 {$page_info['page']} 页</div>
						{/if}
					</div>
					<div class="p_r">{$pagination}</div>
				</td>
			</tr>
		</table>
	{/if}
</div>

{literal}
	<script type="text/javascript">
		//图片缩放
        $('.img').viewer();
        //删除
        function deleteMatter(id) {
                top.swal({
                    title: "确定删除?",
                    text: "删除后不能恢复!",
                    type: "warning",
                    showCancelButton: true,
                    cancelButtonText: '取消',
                    confirmButtonColor: "#DD6B55",
                    confirmButtonText: "确定",
                    closeOnConfirm: false
                }, function () {
                    $.ajax({
                        url: 'matter.php?do=delete',
                        type: 'post',
                        data: {'id': id},
                        dataType: 'json',
                        success: function (re) {
                            if (re.type == 'yes') {
                                $("#d"+id).remove();
                                setTimeout(function () {
                                    top.swal("删除成功！", "success")
                                }, 100);
                            } else {
                                top.swal("删除失败！请联系管理员",  "error");
                                location.reload();
                            }
                        }
                    });
                });
        }
	</script>
{/literal}
</body>
<html>